//
//  ViewController.m
//  Corpse
//
//  Created by dllo on 16/6/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "Slider.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    [self crea];
    [self sliderr];
}
-(void)crea{
    UIImage *back = [UIImage imageNamed:@"BackGround.png"];
   
    UIImageView *mage =[[UIImageView alloc]initWithImage:back];
   
    mage.frame = [UIScreen mainScreen].bounds;
    
    [self.view addSubview:mage];
   
    [mage release];
  
    
}
-(void)sliderr{
    Slider *slider = [[Slider alloc]initWithFrame:CGRectMake(50, 100,200, 20)];
    [self.view addSubview:slider];
    [slider release];
    [slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
    
    
    
}





-(void)sliderAction:(Slider*)slid{
    UIImageView *anima =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"BZombie1.tiff"]];
    anima.frame = CGRectMake(200, 300, 100, 100);
    [self.view addSubview:anima];
    [anima release];
    UIImageView *anima1 =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"BZombie1.tiff"]];
    anima1.frame = CGRectMake(200, 100, 200, 200);
    [self.view addSubview:anima1];
    [anima1 release];
    UIImageView *flowe = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"flower1.tiff"]];
    flowe.frame = CGRectMake(30, 180, 100, 100);
    [self.view addSubview:flowe];
    [flowe release];
    UIImageView *zome = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Zombie0.tiff" ]];
    zome.frame = CGRectMake(200, 420, 200, 200);
    [self.view addSubview:zome];
    [zome release];
    UIImageView *gua = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"gua1.tiff"]];
    gua.frame = CGRectMake(30, 350, 150, 150);
    [self.view addSubview:gua];
    [gua release];
    UIImageView *plants =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"plants1.tiff"]];
    plants.frame = CGRectMake(20, 460, 200, 200);
    [self.view addSubview:plants];
    [plants release];
    

    
    
    
    NSMutableArray *muta = [NSMutableArray arrayWithCapacity:25];
    NSMutableArray *muta1 =[NSMutableArray arrayWithCapacity:25];
    NSMutableArray *mutaFlow = [NSMutableArray arrayWithCapacity:18];
    NSMutableArray *mutaZom = [NSMutableArray arrayWithCapacity:21];
    NSMutableArray *mutaPla = [NSMutableArray arrayWithCapacity:9];
    NSMutableArray *mutaGua = [NSMutableArray arrayWithCapacity:16];

    for(int i = 1; i <= 25; i++){
        NSString *name =[NSString stringWithFormat:@"BZombie%d.tiff",i];
        UIImage *animage = [UIImage imageNamed:name];
        [muta addObject:animage];
        [muta1 addObject:animage];
       
        }
    for(int j = 1; j <= 18; j++){
            NSString *name =[NSString stringWithFormat:@"flower%d.tiff",j];
            UIImage *animage = [UIImage imageNamed:name];
            [mutaFlow addObject:animage];
           
            }
   for (int k = 21; k >= 0;k--) {
                NSString *name =[NSString stringWithFormat:@"Zombie%d.tiff",k];
                UIImage *mage = [UIImage imageNamed:name];
                [mutaZom addObject:mage];

               

                }

             for (int l = 9; l > 0; l--) {
                    NSString *name = [NSString stringWithFormat:@"plants%d.tiff",l];
                    UIImage *mage = [UIImage imageNamed:name];
                     [mutaPla addObject:mage];
              }
            for (int m  = 16; m > 0; m--) {
                        NSString *name =[NSString stringWithFormat:@"gua%d.tiff",m];
                        UIImage *mage = [UIImage imageNamed:name];
                        [mutaGua addObject:mage];
                        
                    }
    
    
    
    
    
    
   
    anima.animationImages = muta;
    anima1.animationImages = muta;
    gua.animationImages =mutaGua;
    plants.animationImages = mutaPla;
    zome.animationImages =mutaZom;
    flowe.animationImages = mutaFlow;
   
    
    
    
    
    
    
    plants.animationDuration = 1 - slid.value/1;
    anima1.animationDuration = 0.5;
    gua.animationDuration = 1;
    anima.animationDuration = 1;
    flowe.animationDuration = 1;
    zome.animationDuration = 1;
    [zome startAnimating];
    [anima1 startAnimating];
    [anima startAnimating];
    [flowe startAnimating];
    [gua startAnimating];
    [plants startAnimating];




}







@end
